package org.recruit.system.controller;

import java.util.List;

import org.recruit.system.domain.Companyintroduction;
import org.recruit.system.service.ICompanyintroductionService;
import org.recruit.system.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 企业简介Controller
 *
 * @author teapot
 * @date 2020-11-12
 */
@Controller
@RequestMapping("/system/companyintroduction")
public class CompanyintroductionController {
    private String prefix = "system/companyintroduction";

    @Autowired
    private ICompanyintroductionService companyintroductionService;

    @GetMapping()
    public String companyintroduction() {
        return prefix + "/companyintroduction";
    }

    /**
     * 查询企业简介列表
     */
    @PostMapping("/list")
    @ResponseBody
    public AjaxResult list(Companyintroduction companyintroduction) {
        //startPage();
        List<Companyintroduction> list = companyintroductionService.selectCompanyintroductionList(companyintroduction);
        return AjaxResult.success(list);
    }


    /**
     * 新增企业简介
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存企业简介
     */
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Companyintroduction companyintroduction) {
        return AjaxResult.success(companyintroductionService.insertCompanyintroduction(companyintroduction));
    }

    /**
     * 修改企业简介
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        Companyintroduction companyintroduction = companyintroductionService.selectCompanyintroductionById(id);
        mmap.put("companyintroduction", companyintroduction);
        return prefix + "/edit";
    }

    /**
     * 修改保存企业简介
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Companyintroduction companyintroduction) {
        return AjaxResult.success(companyintroductionService.updateCompanyintroduction(companyintroduction));
    }

    /**
     * 删除企业简介
     */
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return AjaxResult.success(companyintroductionService.deleteCompanyintroductionByIds(ids));
    }
}
